<template>
  <div class="myPromotion">
    <TopromoteNav></TopromoteNav>
    <div class="myPromotion_top">
      <div class="myPromotion_top_left">
        <div class="myPromotion_top_title">
          <div class="top_title_dd">用户激励计划</div>
          <div class="top_title_dt">将“AI狗”产品推荐给你的的好友，赚取<b>积分</b>和<b>佣金</b>。</div>
        </div>
        <div class="myPromotion_top_content">
          <div class="top_content_dd">发送链接邀请好友注册，即可获得如下权益：</div>
          <div class="top_content_dt">
            <div class="content_dt_list"><span><i class="el-icon-check"></i></span>好友注册成功后您可获得{{ config.reward_points }}积分；</div>
            <div class="content_dt_list"><span><i class="el-icon-check"></i></span>好友注册成功后您可以获取“ChatDOG”{{ config.complimentary_chat_days }}天VIP会员；</div>
            <div class="content_dt_list"><span><i class="el-icon-check"></i></span>好友每笔充值消费您可以获取{{ config.recharge_rebate }}%的返拥。</div>
          </div>
        </div>
      </div>
      <div class="myPromotion_top_right"><img src="@a/img/bg33.jpg"/></div>
    </div>
    <div class="myPromotion_invite">
      <div class="myPromotion_invite_title">邀请文案示例</div>
      <div class="myPromotion_invite_txt">
        <div v-for="(item, index) in inviteList" :key="index" class="invite_txt_list">
          <div class="txt_list_dd">
            <span></span>
            <span></span>
            <span></span>
          </div>
          <div class="txt_list_dt">
            <div class="list_dt_title">{{ item.title }}</div>
            {{ item.url }}
            <div class="list_dt_btn">
              <span @click="copyText(item.title+'\n'+item.url)">复制</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!--<div class="myPromotion_invite myPromotion_bottom">
      <div class="myPromotion_invite_title">邀请文案示例</div>
      <div class="myPromotion_bottom_cord"><img src="@a/img/bg32.jpg"/></div>
      <div class="myPromotion_bottom_title">用微信扫一扫分享页面给好友</div>
    </div>-->
  </div>
</template>


<script>
    import TopromoteNav from "@c/common/topromoteNav/topromoteNav";

    export default {
        name: "myPromotion",
        data() {
            return {
              inviteList: [],
              config:{},
            };
        },
        components: {
          TopromoteNav
        },
        methods:{
          // 复制文本内容到剪贴板
          copyText(text) {
            const tempInput = document.createElement('input')
            tempInput.value = text
            document.body.appendChild(tempInput)
            tempInput.select()
            document.execCommand('copy')
            document.body.removeChild(tempInput)
            this.$message({
                message: '已复制',
                type: 'success'
            });
          }
        },
      created(){
          let that = this;
          this.axios.post('/api/member/getShare').then(
              res => {
                  if(res.code === 1) {
                    that.config = res.result
                    that.inviteList = res.result.inviteList
                  }
              }
          )
      }

    }
</script>

<style>
@import "myPromotion.css";
</style>
